package com.hu.constant;

/**
 * Redis 常量
 */
public interface RedisConstant {

    /**
     * 用户签到记录的 Redis key 前缀
     */
    String USER_SIGN_IN_REDIS_KEY_PREFIX = "user:signins";

    /**
     * 用户点赞题目的Redis key
     * like:problem:<problem_id>
     * Set of user_ids who liked the problem
     */
    String USER_QUESTION_LIKE_REDIS_KEY_PREFIX = "like:problem";

    /**
     * 用户收藏题目的 Redis key
     * collect:problem:<problem_id>
     * Set of user_ids who collected the problem
     */
    String USER_QUESTION_COLLECT_REDIS_KEY_PREFIX = "collect:problem";

    /**
     * 获取用户签到记录的 Redis Key
     * @param year 年份
     * @param userId 用户 id
     * @return 拼接好的 Redis Key
     */
    static String getUserSignInRedisKey(int year, long userId) {
        return String.format("%s:%s:%S", USER_SIGN_IN_REDIS_KEY_PREFIX, year, userId);
    }
    static String getUserQuestionLikeRedisKey(long questionId) {
        return String.format("%s:%S", USER_QUESTION_LIKE_REDIS_KEY_PREFIX, questionId);
    }
    static String getUserQuestionCollectRedisKey(long questionId) {
        return String.format("%s:%S", USER_QUESTION_COLLECT_REDIS_KEY_PREFIX, questionId);
    }
}
